#lang racket

(include "commun.rkt")
(include "tp2_commuter.rkt")

(define (p->i lst) 
  (cond [(emtpy? lst) lst]
        [(list?)]))




(define (infix->prefix expr)
        (prefixer (reverse expr) '() '() (list '+ '- '* '/ '^))
)
(define (prefixer expr stack output ops)
        (cond
        ((null? expr)
                (pop-to-empty stack output))
        ((member? (car expr) ops)
                (cond
                ((null? stack)
                        (prefixer (cdr expr) (append (list (car expr)) stack) output ops))
                ((> (index ops (car expr) 0) (index ops (car stack) 0))
                        (prefixer (cdr expr) (append (list (car expr)) stack) output ops))
                (else
                        (prefixer expr (cdr stack) (append (list (car stack)) output) ops))))
        (else
                (prefixer (cdr expr) stack (append (list (car expr)) output) ops))))

(define (pop-to-empty stack output)
        (if (null? stack)
                output
        (pop-to-empty (cdr stack) (list (car stack) output)))